<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<title>批量上传文件</title>
</head>
<body>
  <div style="text-align: center;">
    <a href="download.jsp">下载已上传的文件</a>
    <form action="upload" method="post" enctype="multipart/form-data">
      <fieldset>
        <legend>选择上传的文件</legend>
        <input type="file" id="var0" name="files" multiple>
        <input type="submit" id="var1" value="上传">
      </fieldset>
    </form>
    <c:if test="${error != null && error != ''}">
      <c:out value="${requestScope.error}" />
    </c:if>
  </div>
  <script type="text/javascript">
    var var0 = document.querySelector("#var0");
    var var1 = document.querySelector("#var1");
    var0.addEventListener("change", function () {
      var files = var0.files;
      for (let file of files) {
        if (file.size > 134217728) {
          window.alert("上传的文件中存在长度大于128MB的文件");
          var1.disabled = true;
          return;
        }
        var1.disabled = false;
      }
    })
  </script>
</body>
</html>